package Swing;

import MsgSystem.ImpInstantMessage;
import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileNameExtensionFilter;

public class Upload_popup extends javax.swing.JFrame {

    ImpInstantMessage itm;
    FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG & GIF Images", "jpg", "gif");
    File fileObtained;
    JFileChooser chooser;

    public File getFile() {
        
        return chooser.getSelectedFile();        
    }

    public Upload_popup() {
        chooser = new JFileChooser();
        chooser.setFileFilter(filter);
        int returnVal = chooser.showOpenDialog(null);
        
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            fileObtained = chooser.getSelectedFile();
            
        }
        if (returnVal != JFileChooser.CANCEL_OPTION && (fileObtained == null || fileObtained.getName().equals(""))) {
            JOptionPane.showMessageDialog(null, "Incorrect filename",
                    "Incorrect filename", JOptionPane.ERROR_MESSAGE);
        }
        
        
    }
}
